/*
 * 
 * Created on Jul 27, 2005
 */
package com.wgo.precise.client.ui.view.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.eclipse.ui.views.properties.IPropertyDescriptor;

import com.wgo.precise.client.ui.model.AbstractPropertySpesification;
import com.wgo.precise.client.ui.model.PropertySetWrapper;
import com.wgo.precise.client.ui.model.RequirementWrapper;

import remato.domain.common.Requirement;

/**
 * 
 * @author Petter L. H. Eide
 * @version $Id: RequirementPropertySource.java,v 1.2 2006-01-30 21:52:32 petterei Exp $
 */
public class RequirementPropertySource extends ModelItemPropertySource {

    private String requirementCategory = Requirement.class.getSimpleName() + " details";
    
    public RequirementPropertySource(RequirementWrapper node) {
        super(node);
    }

    @Override
    public IPropertyDescriptor[] getPropertyDescriptors() {
        List<IPropertyDescriptor> descs = new ArrayList<IPropertyDescriptor>();
        descs.addAll(Arrays.asList(super.getPropertyDescriptors()));
        Collection<AbstractPropertySpesification> defs = new ArrayList<AbstractPropertySpesification>();
        defs.addAll(RequirementWrapper.getSortedRequirementSpesifications());
        IPropertyDescriptor[] staticDescriptors = createPropertyDescriptors(defs, requirementCategory);
        descs.addAll(Arrays.asList(staticDescriptors));
//        RequirementPlugin.log(getClass(), "Number of properties bla bla.. : " + ((RequirementWrapper)getItem()).getUserDefinedTypes().size());
        ((RequirementWrapper)getItem()).verifyProperties();
//        RequirementPlugin.log(getClass(), "Number of properties bla bla.. : " + ((RequirementWrapper)getItem()).getUserDefinedTypes().size());
        // for the spesific type:
        Collection<AbstractPropertySpesification> modelDefs; 
        for (PropertySetWrapper set : ((RequirementWrapper)getItem()).getPropertyDefinitionSets()) {
        	modelDefs = set.getAbstractPopertyDefinitions();
            IPropertyDescriptor[] descriptors = createPropertyDescriptors(modelDefs, set.getSimpleName());
            descs.addAll(Arrays.asList(descriptors));
        }
        return descs.toArray(new IPropertyDescriptor[descs.size()]);
    }

}
/**
 * 
 * Changelog:
 * 
 * $Log: RequirementPropertySource.java,v $
 * Revision 1.2  2006-01-30 21:52:32  petterei
 * implemented wrapper factory and lazy wrapper-instantiation of parents
 * implemented a "system" for each top-node type
 * added top-categories for all top-nodes
 * implemented some interfaces for the wrappers, and started using these
 *
 * Revision 1.1  2006-01-23 19:58:37  petterei
 * initial commit for client, fitting the alternative session implementation
 *
 * Revision 1.2  2005-12-08 22:34:05  petterei
 * fixed functionality for showing userdefined types  for requirements
 *
 * Revision 1.1  2005-12-07 07:25:35  petterei
 * gui & logic for relationships
 *
 * Revision 1.6  2005-12-03 14:07:02  petterei
 * *** empty log message ***
 *
 * Revision 1.5  2005-11-28 21:45:10  petterei
 * refactored most of the client model to wrap the domain-model
 * added some functionality for new domain-model-concepts
 *
 * Revision 1.4  2005/10/24 16:25:36  petterei
 * *** empty log message ***
 *
 * Revision 1.3  2005/10/02 21:31:16  petterei
 * client with new domain model
 *
 * Revision 1.2  2005/09/30 15:33:23  petterei
 * *** empty log message ***
 *
 * Revision 1.1  2005/09/29 16:41:42  petterei
 * *** empty log message ***
 *
 * Revision 1.2  2005/08/25 18:14:26  peide3
 * updated services interface
 *
 * Revision 1.1  2005/08/23 06:38:13  peide3
 * *** empty log message ***
 *
 * Revision 1.1  2005/07/31 22:55:10  petterei
 * initial commit
 *
 */
